<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()

const handleLogout = () => {
  // 这里可以添加退出登录的逻辑，比如清除token等
  // ...
  
  // 跳转到登录页面
  router.push('/login')
}
</script>

<template>
<el-container>
  <el-aside>
    <h1>管理后台</h1>
    
     <el-menu :router="true">
      <el-menu-item index="/books">
        <template #title>商品管理</template>
      </el-menu-item>
          <el-menu-item index="/orders">
        <template #title>订单管理</template>
          </el-menu-item>
          <el-menu-item index="/carts">
        <template #title>购物车管理</template>
           </el-menu-item>
      <el-menu-item index="/users">
        <template #title>会员管理</template>
      </el-menu-item>
    </el-menu>
  </el-aside>
  <el-container>
    <el-header>
      <div>
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item>
            <a href="/books">商品管理</a>
          </el-breadcrumb-item>
        </el-breadcrumb>
      </div>
      <div>
        <el-button plain @click="handleLogout">退出</el-button>
      </div>
    </el-header>
    <el-main>
      <router-view></router-view>
    </el-main>
  </el-container>
</el-container>
</template>

<style scoped>
.el-container{
  height: 100%;
}

.el-aside{
  width:200px;
  height:100%;
  background-color: rgb(219, 114, 88);
}
.el-header{
  height:60px;
  background-color: rgb(223, 113, 62);
  color: white;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
.el-header >div{
  line-height: 60px;
  width: 400px;
  text-align: right;
}
.el-breadcrumb{
  line-height: 60px;
  color: aliceblue;
}

.el-main{
  background-color: white;
}
.el-aside h1{
  width: 200px;
  height: 60px;
  color:white;
  text-align: center;
  line-height: 60px;
  font-size: 1.5rem;
}
</style>